
/**
 * Dynamically generated DBObjects script.
 * 
 * This script provides an interface to the DBObject you created.
 * 
 * The eddUser object extends the DB.Object.
 * 
 * 
 */
// TODO = Overwrite
var SNAppAccess = new Class({
	
	Extends: SnappUser,
	
	options: {
		actions: {
			login: 'access.Login',
			checkSession: 'access.CheckSession'	
		},
		
		events: {
			login: function(accObj) {
				snapp.session.handleLogin(accObj);
			},
			
			checkSession: function(accObj) {
				snapp.session.handleSessionCheck(accObj);
			}
		}
	},
	
	// validation check
	isValid: false,
	
	// test for given permission
	hasPermit: function(prmt) {
		rv = this.getProperty('permits').containsKey(prmt);
		if (!rv) alert('You do not have permission to perform this task.');
		return rv;
	},
	
	// get the hashcode for the given permit
	getPermitCode: function(prmt) {
		return this.getProperty('permits').getProperty(prmt);
	}, 
	
	// get the security check string
	getSecCheck: function(prmt) {
		return prmt + "::" + this.getPermitCode(prmt);
	},
	
	doLogin: function(frm) {
		snapp.session.waiter = new Waiter($('login_div'),{msg:'Validating...'});
		snapp.session.waiter.start();

		credstatact = 1;
		this.setProperty('status',credstatact);
		this.login(frm);
	}
});
